<?php

require "../classes/ContactPark.class.php";
require "../classes/ParkDAO.class.php";
require "../classes/ConnectionFactory.class.php";
require "checksDate.action.php";

$park=new ContactPark();
$date=new checksDate();

$park->setId($_POST['id']);
$park->setIdClients($_POST['idcli']);
$park->setIdCar($_POST['idcar']);
$park->setDatein($date->convertsDatehora($_POST['dateIn']));
$park->setDateout($date->convertsDatehora($_POST['dateout']));
$park->setHours($_POST['parkHoraInput']);
$park->setFare($_POST['tarifa']);
$park->setSatatus(1);
$park->setTotal($_POST['parkValorInput']);


$cf = new ConnectionFactory();
    $db = $cf->getConnection();
    
    $dao = new ParkDAO($db);
    $result=$dao->update($park);
?>


<script>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />;
    var cadTest = <?php echo $result; ?>;
           
    if(cadTest){
        alert("Cadastro Efetuado Com Sucesso!");
        setTimeout("document.location = '../index.php'",500);
       
    }else{
       
        alert("Não Foi Possível Realizar o Cadastro!");
        setTimeout("document.location = '../index.php'",500);
    }
    
             
</script>
